import request from "@/utils/request";

// 分类
export function cate(params = {}) {
  if (!params.module) params.module = "app-invitation";
  if (!params.platform) params.module = "question";
  return request({
    url: "/api/halo-dashboard/v1/article/category",
    params
  });
}
// 列表
export function list(params = {}) {
  if (!params.module) params.module = "app-invitation";
  if (!params.platform) params.module = "question";
  return request({
    url: "/api/halo-dashboard/v1/article",
    params
  });
}
// 添加
export function add(data) {
  return request({
    url: "/api/halo-dashboard/v1/article",
    method: "post",
    data
  });
}
// 更新
export function update(data) {
  return request({
    url: `/api/halo-dashboard/v1/article/${data.id}`,
    method: "put",
    data
  });
}
// 详情
export function detail(id) {
  return request({
    url: `/api/halo-dashboard/v1/article/${id}`,
    method: "get",
    params: { id }
  });
}
// 删除
export function remove(id) {
  return request({
    url: `/api/halo-dashboard/v1/article/${id}`,
    method: "delete",
    data: { id }
  });
}
// 启用禁用
export function changeStatus(data) {
  const url = !data.status
    ? `/api/halo-dashboard/v1/article/${data.id}/resume`
    : `/api/halo-dashboard/v1/article/${data.id}/forbid`;
  return request({
    url,
    method: "patch"
  });
}
